#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>


using namespace std;

class CStudent
{
public:
    CStudent()
    {

    }
    ~CStudent()
    {
        delete []name;
    }


    void setName(const char * newName)
    {
        if (newName) {
            int len = strlen(newName);
            name = new char[len + 1];
            strcpy(name, newName);
        }
    }


    void setAge(const unsigned short newAge)
    {
        age = newAge;
    }


    const char *  getName()
    {
        printf("name address is :0x%x\n", name);
        return name;
    }

    unsigned short getAge()
    {
        return age;
    }

    /* data */

private:
    char *name;
    unsigned short age;

};


CStudent createStudent(const char *name, const unsigned short age)
{
    CStudent student;
    student.setName(name);
    student.setAge(age);
    cout << "Name: " << student.getName() << ";Age :" << student.getAge() << endl;
    return student;
}


void test()
{
    CStudent studentA;

    studentA.setName("zhangsan");
    studentA.setAge(23);
    cout << "Name: " << studentA.getName() << ";Age :" << studentA.getAge() << endl;


    studentA = createStudent("lisi", 23);
    cout << "Name: " << studentA.getName() << ";Age :" << studentA.getAge() << endl;
}


void fun()
{
    static int a = 3;
    a++;
    cout << a << endl;

}


int main()
{
    test();
    return 0;
}
